package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.CheckGroup;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CheckGroupDao {
    Page<CheckGroup> findPage(QueryPageBean queryPageBean);

    @Select("select * from t_checkgroup where id = #{id}")
    CheckGroup findById(Integer id);

    CheckGroup findCheckGroupById(Integer id);

    @Insert("INSERT INTO t_checkgroup_checkitem (checkgroup_id,checkitem_id) VALUES (#{checkGroupId},#{checkItemId})")
    void addgroup_item(@Param("checkGroupId") Integer checkGroupId, @Param("checkItemId") Integer checkItemId);


    void add(CheckGroup checkGroup);

    @Delete("delete from t_checkgroup where id = #{id}")
    void delete(Integer id);

    void update(CheckGroup checkGroup);


    @Select("SELECT checkitem_id FROM t_checkgroup_checkitem where checkgroup_id = #{checkGroupId} ")
    Integer[] findItemIds(Integer checkGroupId);

    @Delete("delete from t_checkgroup_checkitem where checkgroup_id = #{checkGroupId}")
    void deleteGroupItem(Integer checkGroupId);

    @Select("select * from t_checkgroup")
    List<CheckGroup> findAll();
}
